<template>
  <div class="myRegionList">
    <div v-for="(row, index) in list" :key="index" class="list-row">
      <div class="row">
        <div
          class="radio"
          :class="{ active: row.checked }"
          @click="handleClickRow(index)"
        ></div>
        <div class="label">{{ row.name }}</div>
      </div>
      <div class="list-city">
        <div
          v-for="(col, i) in row.city"
          :key="i"
          class="list-col"
          :class="{ selected: col.checked }"
          @click="handleClickCol(index, i)"
        >
          {{ col.name }}
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    list: {
      default: () => [],
    },
  },
  computed: {},
  methods: {
    handleClickRow(index) {
      this.$emit("handleClickRow", index);
    },
    handleClickCol(index, i) {
      this.$emit("handleClickCol", {
        index,
        i,
      });
    },
  },
};
</script>

<style lang="less" scoped>
.myRegionList {
  width: 100%;
  height: 100%;
  padding: 20px 60px 20px 60px;
  box-sizing: border-box;
  overflow: auto;
  .list-row {
    .list-city {
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      padding-left: 30px;
      .list-col {
        width: 86px;
        height: 25px;
        line-height: 25px;
        text-align: center;
        background-color: #f5f5f5;
        margin: 0 15px 15px 0;
        user-select: none;
        cursor: pointer;
        color: #808595;
        font-size: 12px;
      }
    }
    .selected {
      color: #e3a827 !important;
      background-color: #fef2d8 !important;
    }
  }
}
.row {
  display: flex;
  align-items: center;
  width: 100%;
  height: 44px;
  margin-bottom: 15px;
  .radio {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid #e3a827;
    transition: all 0.1s;
    margin-right: 15px;
    cursor: pointer;
    // &:hover {
    //   border: 1px solid #e3a827;
    // }
  }
  .label {
    color: #333;
    font-size: 14px;
  }
}

.active {
  position: relative;
  background-color: #fef2d8;
  &::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: #e3a827;
  }
}
</style>